package com.oneandseven.dajia.config;

import com.oneandseven.dajia.utils.IdWorker;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
public class BaseConfig {

    @Bean
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(3); // 核心线程数
        executor.setMaxPoolSize(3); // 最大线程数
        executor.setQueueCapacity(50); // 队列大小
        executor.setThreadNamePrefix("redis-listener-"); // 线程名称前缀
        executor.initialize();
        return executor;
    }

    @Bean
    public IdWorker idWorker() {
        return new IdWorker(1,1,0);
    }
}